/**
 * Created by IntelliJ IDEA.
 * User: Administrator
 * Date: Dec 31, 2009
 * Time: 10:52:50 AM
 * To change this template use File | Settings | File Templates.
 */
import dk.brics.automaton.Automaton;
import java.util.List;
import java.util.Set;
import org.jdom.Element;

// Referenced classes of package dk.brics.dsd:
//            Regexp, Schema, Context

class StringRegexp extends Regexp
{

    StringRegexp(Element element, Schema schema)
    {
        value = element.getAttributeValue("value");
    }

    public Element toXML(Context context)
    {
        Element element = new Element("string", "http://www.brics.dk/DSD/2.0");
        if(value != null)
            element.setAttribute("value", value);
        return element;
    }

    boolean match(String s, Context context)
    {
        if(value == null)
            return true;
        else
            return value.equals(s);
    }

    Automaton toAutomaton(Context context)
    {
        if(value == null)
            return getAllchars().repeat();
        else
            return Automaton.makeString(value);
    }

    void getMentioned(Context context, Set set, List list)
    {
        set.add(null);
    }

    boolean checkSimple(Context context)
    {
        return true;
    }

    String value;
}
